

package org.springframework.security.authentication;

import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;

/**
 * 1.AuthenticationProvider有点类似AuthenticationManager，但是它多了一个supports方法。
 *
 * @author Ben Alex
 */
public interface AuthenticationProvider {
	// ~ Methods
	// ========================================================================================================


	/**
	 *  返回null，表示不能断定
	 * @param authentication  Authentication信息
	 * @return 返回Authentication，表示认证成功
	 * @throws AuthenticationException 抛出AuthenticationException异常，表示用户输入了无效的凭证
	 */
	Authentication authenticate(Authentication authentication)
			throws AuthenticationException;

	/**
	 * 用来判断是否支持给定的Authentication类型
	 *
	 * @param authentication 认证信息
	 *
	 * @return <code>true</code> if the implementation can more closely evaluate the
	 * <code>Authentication</code> class presented
	 */
	boolean supports(Class<?> authentication);
}
